package com.edu.web.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.edu.entity.GreenUser;
import com.edu.service.impl.GreenUserSericeImpl;
import com.edu.service.impl.ReasonServiceImpl;





/**
 * Servlet implementation class donationUserServlet
 */
@WebServlet("/donationUserServlet")
public class donationUserServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		GreenUserSericeImpl green =new GreenUserSericeImpl();
		GreenUser greenUser=new GreenUser();
		greenUser.setDonationName(request.getParameter("first_name"));
		greenUser.setDonationAddress(request.getParameter("address"));
		greenUser.setDonationEmail(request.getParameter("email"));
		greenUser.setCountry(request.getParameter("country"));
		greenUser.setDonationPhone(request.getParameter("phone"));
		greenUser.setDonationMoney(Integer.parseInt(request.getParameter("inlineRadioOptions")));
		greenUser.setRemark(request.getParameter("xian"));
		ReasonServiceImpl Reason =new ReasonServiceImpl();
		String names=request.getParameter("xian");
		int numss=Integer.parseInt(request.getParameter("inlineRadioOptions"));
		int nums=Reason.allInformation(names, numss);
		int numes = green.InsertUser(greenUser);
		if(numes==1) {
			request.getRequestDispatcher("404.jsp").forward(request, response);
		}
		request.getRequestDispatcher("false.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
